home *** CD-ROM | disk | FTP | other *** search
- on Timer___________________________
- end
-
- on InitTimer
- global gMaxTimer, gToday, gTimerToDoList, gTempTimerAll, gTimerAll, gTempRememberTimer, gRememberTimer, gTempTimerOnList, gTimerOnList, gTempTimerHourList, gTimerHourList, gTempTimerDayList, gTimerDayList, gTempTimerBy, gTimerBy, gAppliedHourList, gAppliedDayList, gDaysInterval, gHoursInterval, gMinutesInterval, gStartMonth, gStartDay, gStartYear, gStartHour, gStartMinute, gStartInterval, gTheInterval, gLastMomentDone
- set gToday to Sinistra(OSConstDate(), 10)
- set gTimerToDoList to []
- set gTimerAll to 0
- set gRememberTimer to 0
- set gMaxTimer to 7
- set gTimerBy to 1
- set gTempTimerBy to gTimerBy
- set gTempTimerOnList to []
- set gTimerOnList to []
- set gTempTimerHourList to []
- set gTimerHourList to []
- set gTempTimerDayList to []
- set gTimerDayList to []
- repeat with i = 1 to gMaxTimer
- append(gTempTimerOnList, 1)
- append(gTimerOnList, 1)
- append(gTempTimerHourList, " ")
- append(gTimerHourList, " ")
- append(gTempTimerDayList, -1)
- append(gTimerDayList, -1)
- end repeat
- set gAppliedHourList to []
- set gAppliedDayList to []
- set gDaysInterval to -1
- set gHoursInterval to -1
- set gMinutesInterval to -1
- set gStartMonth to -1
- set gStartDay to -1
- set gStartYear to -1
- set gStartHour to -1
- set gStartMinute to -1
- set gStartInterval to -1
- set gTheInterval to -1
- set gLastMomentDone to 0
- set the textHeight of member "fOnOffTimer" to 18
- set the textHeight of member "fHourList" to 18
- set the textHeight of member "fDayList" to 18
- end
-
- on GoTimer
- global gTempTimerAll, gTimerAll, gTempTimerWhenNeeded, gTimerWhenNeeded, gTempRememberTimer, gRememberTimer, gTempTimerBy, gTimerBy, gDaysInterval, gHoursInterval, gMinutesInterval, gStartMonth, gStartDay, gStartYear, gStartHour, gStartMinute, gTempTimerOnList, gTimerOnList, gTempTimerHourList, gTimerHourList, gTempTimerDayList, gTimerDayList, gMaxTimer, gGrigio, gNero, gSep, gTempDoAndQuit, gDoAndQuit
- if voidp(gTimerAll) then
- set gTimerAll to 0
- end if
- set gTempTimerAll to gTimerAll
- if voidp(gTimerWhenNeeded) then
- set gTimerWhenNeeded to 0
- end if
- set gTempTimerWhenNeeded to gTimerWhenNeeded
- if voidp(gRememberTimer) then
- set gRememberTimer to 0
- end if
- set gTempRememberTimer to gRememberTimer
- if voidp(gTimerBy) then
- set gTimerBy to 1
- end if
- set gTempTimerBy to gTimerBy
- put EMPTY into field "fHourList"
- put EMPTY into field "fDayList"
- set the foreColor of field "fOnOffTimer" to gNero
- set the foreColor of field "fHourList" to gNero
- set the foreColor of field "fDayList" to gNero
- set tempHour to EMPTY
- set tempDay to EMPTY
- set gTempTimerOnList to value(string(gTimerOnList))
- set gTempTimerHourList to value(string(gTimerHourList))
- set gTempTimerDayList to value(string(gTimerDayList))
- set gTempDoAndQuit to gDoAndQuit
- repeat with i = 1 to gMaxTimer
- set myItem to getAt(gTempTimerHourList, i)
- put myItem & RETURN after tempHour
- set myItem to WhichDayString(getAt(gTempTimerDayList, i))
- put myItem & RETURN after tempDay
- end repeat
- delete char -30000 of tempHour
- delete char -30000 of tempDay
- put tempHour into field "fHourList"
- put tempDay into field "fDayList"
- repeat with i = 1 to gMaxTimer
- if not getAt(gTempTimerOnList, i) then
- set the foreColor of line i of field "fOnOffTimer" to gGrigio
- set the foreColor of line i of field "fHourList" to gGrigio
- set the foreColor of line i of field "fDayList" to gGrigio
- end if
- end repeat
- if gDaysInterval = -1 then
- put "0" into field "fDaysIntervallo"
- else
- put gDaysInterval into field "fDaysIntervallo"
- end if
- if gHoursInterval = -1 then
- put "1" into field "fHoursIntervallo"
- else
- put gHoursInterval into field "fHoursIntervallo"
- end if
- if gMinutesInterval = -1 then
- put "0" into field "fMinutesIntervallo"
- else
- put gMinutesInterval into field "fMinutesIntervallo"
- end if
- if gStartMonth = -1 then
- put TodayMonth() into field "fStartMonth"
- else
- put gStartMonth into field "fStartMonth"
- end if
- if gStartDay = -1 then
- put TodayDay() into field "fStartDay"
- else
- put gStartDay into field "fStartDay"
- end if
- if gStartYear = -1 then
- put TodayYear() into field "fStartYear"
- else
- put gStartYear into field "fStartYear"
- end if
- if gStartHour = -1 then
- put NowHour() into field "fStartHour"
- else
- put gStartHour into field "fStartHour"
- end if
- if gStartMinute = -1 then
- put NowMinute() into field "fStartMinute"
- else
- put gStartMinute into field "fStartMinute"
- end if
- go("Timing")
- SetMenuCredits()
- end
-
- on SetOneTimerOnOff myLinea
- global gTempTimerOnList, gGrigio, gNero
- set a to the foreColor of char 1 of line myLinea of field "fOnOffTimer" = gNero
- set a to not a
- if a then
- set colore to gNero
- set myValore to 1
- else
- set colore to gGrigio
- set myValore to 0
- end if
- set the foreColor of char 1 of line myLinea of field "fOnOffTimer" to colore
- set the foreColor of line myLinea of field "fHourList" to colore
- set the foreColor of line myLinea of field "fDayList" to colore
- setAt(gTempTimerOnList, myLinea, myValore)
- end
-
- on AskForHour myLinea
- global gTempTimerHourList
- if the optionDown then
- put " " into line myLinea of field "fHourList"
- setAt(gTempTimerHourList, myLinea, " ")
- else
- OpenHourWind(myLinea)
- end if
- end
-
- on ImportTimerHour myLinea
- global gHour, gMinute, gTempTimerHourList, gTempTimerDayList
- if length(gHour) = 1 then
- put "0" before gHour
- end if
- if length(gMinute) = 1 then
- put "0" before gMinute
- end if
- set myHourAndMinute to gHour & ":" & gMinute
- put myHourAndMinute into line myLinea of field "fHourList"
- if line myLinea of field "fDayList" = " " then
- put "Every Day" into line myLinea of field "fDayList"
- setAt(gTempTimerDayList, myLinea, 0)
- end if
- setAt(gTempTimerHourList, myLinea, myHourAndMinute)
- end
-
- on AskForDay myLinea
- global gTempTimerDayList
- if the optionDown then
- put " " into line myLinea of field "fDayList"
- setAt(gTempTimerDayList, myLinea, -1)
- else
- PopTimerDay(myLinea)
- end if
- end
-
- on PopTimerDay riga
- global gTempTimerDayList, gMyStageWidth, gMyStageHeight
- put field "fPopDayMatrice" into field "fPopDay"
- set myPresetLine to WhichDayNumber(line riga of field "fDayList") + 1
- if myPresetLine > 0 then
- put "• " into char 1 to 3 of line myPresetLine of field "fPopDay"
- set deltaPreSet to (myPresetLine - 1) * 12
- else
- set deltaPreSet to 0
- end if
- set mySprite to 24
- set myH to the left of sprite mySprite - 1
- set myV to ((riga - 1) * 18) - 1 + the top of sprite mySprite - deltaPreSet
- if (myV + the height of member "fPopDay" + 4) > gMyStageHeight then
- set myV to gMyStageHeight - the height of member "fPopDay" - 4
- end if
- set the loc of sprite 58 to point(myH, myV)
- set myHT to myH + 79
- set myVT to myV + 41
- set the loc of sprite 56 to point(myHT, myVT)
- updateStage()
- repeat while the stillDown
- if the rollOver = 58 then
- set myRollLine to the mouseLine
- if myRollLine > 0 then
- set the loc of sprite 57 to point(myH, myV + ((myRollLine - 1) * 12))
- set the loc of sprite 59 to point(myH, myV + ((myRollLine - 1) * 12))
- else
- set the loc of sprite 57 to point(-1000, -1000)
- set the loc of sprite 59 to point(-1000, -1000)
- end if
- else
- if the rollOver <> 59 then
- set the loc of sprite 57 to point(-1000, -1000)
- set the loc of sprite 59 to point(-1000, -1000)
- end if
- end if
- updateStage()
- end repeat
- if the rollOver = 59 then
- put WhichDayString(myRollLine - 1) into line riga of field "fDayList"
- setAt(gTempTimerDayList, riga, myRollLine - 1)
- end if
- set the loc of sprite 56 to point(-1000, -1000)
- set the loc of sprite 57 to point(-1000, -1000)
- set the loc of sprite 58 to point(1000, 1000)
- set the loc of sprite 59 to point(1000, 1000)
- updateStage()
- end
-
- on WhichDayString linea
- case linea of
- 0:
- return "Every Day"
- 1:
- return "Monday"
- 2:
- return "Tuesday"
- 3:
- return "Wednesday"
- 4:
- return "Thursday"
- 5:
- return "Friday"
- 6:
- return "Saturday"
- 7:
- return "Sunday"
- (-1):
- return " "
- otherwise:
- return "Every Day"
- end case
- end
-
- on WhichDayNumber stringa
- case stringa of
- "Every Day":
- return 0
- "Monday":
- return 1
- "Tuesday":
- return 2
- "Wednesday":
- return 3
- "Thursday":
- return 4
- "Friday":
- return 5
- "Saturday":
- return 6
- "Sunday":
- return 7
- " ":
- return -1
- otherwise:
- return 0
- end case
- end
-
- on TastoTimer
- global gBianco, gNero
- if (the key = RETURN) or (charToNum(the key) = 3) then
- set mySprite to 39
- else
- if the keyCode = 53 then
- set mySprite to 36
- else
- exit
- end if
- end if
- set myBtnUp to the name of member the member of sprite mySprite
- set myTextMember to the member of sprite (mySprite + 1)
- set the member of sprite mySprite to BtnDw(myBtnUp)
- set the forecolor of myTextMember to gBianco
- updateStage()
- repeat with i = 0 to 15000
- end repeat
- set the member of sprite mySprite to myBtnUp
- set the foreColor of member myTextMember to gNero
- updateStage()
- if mySprite = 39 then
- ApplyTimer()
- else
- if mySprite = 36 then
- GoLista()
- end if
- end if
- end
-
- on ApplyTimer
- global gTempTimerAll, gTimerAll, gTempRememberTimer, gRememberTimer, gTempTimerBy, gTimerBy, gDaysInterval, gHoursInterval, gMinutesInterval, gStartMonth, gStartDay, gStartYear, gStartHour, gStartMinute, gStartInterval, gTheInterval, gLastMomentDone, gTempTimerOnList, gTimerOnList, gTempTimerHourList, gTimerHourList, gTempTimerDayList, gTimerDayList, gMaxTimer, gAppliedHourList, gAppliedDayList, gTempDoAndQuit, gDoAndQuit
- if (gTempDoAndQuit = 1) and (gTempTimerAll = 1) then
- AlertBox("Cannot set the " & QUOTE & "Timer On" & QUOTE & " with " & QUOTE & "On Start: Sync/BackUp and Quit" & QUOTE)
- exit
- end if
- if gTempTimerAll then
- if gTempTimerBy = 1 then
- set k to 0
- repeat with i = 1 to gMaxTimer
- if getAt(gTempTimerOnList, i) then
- if (getAt(gTempTimerHourList, i) <> " ") and (getAt(gTempTimerDayList, i) = -1) then
- AlertBox("Cannot set a Timer without the Day definition on line" && i & ".")
- exit
- end if
- if (getAt(gTempTimerHourList, i) = " ") and (getAt(gTempTimerDayList, i) >= 0) then
- AlertBox("Cannot set a Timer without the Hour definition on line" && i & ".")
- exit
- end if
- if getAt(gTempTimerHourList, i) <> " " then
- set k to k + 1
- end if
- end if
- end repeat
- if k = 0 then
- AlertBox("Cannot set a Timer without Timing.")
- exit
- end if
- else
- set myDays to value(field "fDaysIntervallo")
- set myHours to value(field "fHoursIntervallo")
- set myMinutes to value(field "fMinutesIntervallo")
- set mySomma to myDays + myHours + myMinutes
- if mySomma <= 0 then
- AlertBox("Invalid Timer Interval.")
- exit
- end if
- set myStartYear to value(field "fStartYear")
- set myNoBisestile to myStartYear mod 4
- set myStartMonth to value(field "fStartMonth")
- set myStartDay to value(field "fStartDay")
- if (myStartDay = 31) and ((myStartMonth = 11) or (myStartMonth = 4) or (myStartMonth = 6) or (myStartMonth = 9)) then
- AlertBox("Invalid Starting Date.")
- exit
- end if
- if (myStartMonth = 2) and (myStartDay > 28) then
- if myStartDay > 29 then
- AlertBox("Invalid Starting Date.")
- exit
- else
- if myNoBisestile then
- AlertBox("Invalid Starting Date." && myStartYear && "is not a leap year.")
- exit
- end if
- end if
- end if
- end if
- end if
- set gTimerAll to gTempTimerAll
- set gRememberTimer to gTempRememberTimer
- set gTimerBy to gTempTimerBy
- set gDoAndQuit to gTempDoAndQuit
- set gTimerOnList to value(string(gTempTimerOnList))
- set gTimerHourList to value(string(gTempTimerHourList))
- set gTimerDayList to value(string(gTempTimerDayList))
- if gTimerAll and (gTimerBy = 0) then
- set gDaysInterval to value(field "fDaysIntervallo")
- set gHoursInterval to value(field "fHoursIntervallo")
- set gMinutesInterval to value(field "fMinutesIntervallo")
- set gStartMonth to value(field "fStartMonth")
- set gStartDay to value(field "fStartDay")
- set gStartYear to value(field "fStartYear")
- set gStartHour to value(field "fStartHour")
- set gStartMinute to value(field "fStartMinute")
- end if
- set gAppliedHourList to []
- set gAppliedDayList to []
- if gTempTimerAll then
- if gTimerBy then
- repeat with i = 1 to gMaxTimer
- if getAt(gTempTimerOnList, i) then
- if (getAt(gTempTimerHourList, i) <> " ") and (getAt(gTempTimerDayList, i) >= 0) then
- append(gAppliedHourList, getAt(gTempTimerHourList, i))
- append(gAppliedDayList, getAt(gTempTimerDayList, i))
- end if
- end if
- end repeat
- PrepareTimerToDoList()
- else
- set myStartDay to DaysAnnoZero(gStartYear, gStartMonth, gStartDay)
- set gStartInterval to (24 * 60 * myStartDay) + (60 * gStartHour) + gStartMinute
- set gTheInterval to (24 * 60 * gDaysInterval) + (60 * gHoursInterval) + gMinutesInterval
- set gLastMomentDone to 0
- end if
- end if
- GoLista()
- end
-
- on PrepareTimerToDoList
- global gAppliedHourList, gTimerToDoList
- set gTimerToDoList to []
- set NowMinutes to (60 * NowHour()) + NowMinute()
- set TodayDayOfWeek to ((DaysAnnoZero(TodayYear(), TodayMonth(), TodayDay()) + 3) mod 7) + 1
- set k to k + 0
- repeat with i in gAppliedHourList
- set k to k + 1
- set DayOfWeek to getAt(gAppliedDayList, k)
- if (DayOfWeek = 0) or (DayOfWeek = TodayDayOfWeek) then
- set ListMinutes to (value(Sinistra(i, 2)) * 60) + value(Centro(i, 4, 5))
- if ListMinutes > NowMinutes then
- append(gTimerToDoList, i)
- end if
- end if
- end repeat
- sort(gTimerToDoList)
- end
-
- on DoTimerScript
- global gToday, gAppliedHourList, gAppliedDayList, gTimerToDoList, gMultiAll, gTimerBy, gStartInterval, gTheInterval, gLastMomentDone
- if gTimerBy = 0 then
- set myToday to DaysAnnoZero(TodayYear(), TodayMonth(), TodayDay())
- set thisMoment to (24 * 60 * myToday) + (60 * NowHour()) + NowMinute()
- if gLastMomentDone <> thisMoment then
- set gLastMomentDone to thisMoment
- set YesTimerInterval to (((thisMoment - gStartInterval) mod gTheInterval) = 0) and (thisMoment >= gStartInterval)
- if YesTimerInterval then
- CloseAllWindow()
- DoSynchronize()
- end if
- end if
- else
- set myDay to Sinistra(OSConstDate(), 10)
- if myDay <> gToday then
- set gTimerToDoList to []
- set TodayDayOfWeek to ((DaysAnnoZero(TodayYear(), TodayMonth(), TodayDay()) + 3) mod 7) + 1
- set k to k + 0
- repeat with i in gAppliedHourList
- set k to k + 1
- set DayOfWeek to getAt(gAppliedDayList, k)
- if (DayOfWeek = 0) or (DayOfWeek = TodayDayOfWeek) then
- append(gTimerToDoList, i)
- end if
- end repeat
- sort(gTimerToDoList)
- set gToday to myDay
- end if
- if FindHourToDo() then
- CloseAllWindow()
- DoSynchronize()
- end if
- end if
- end
-
- on FindHourToDo myTime
- global gTimerToDoList
- set NowMinutes to (60 * NowHour()) + NowMinute()
- repeat with j = 1 to count(gTimerToDoList)
- set i to getAt(gTimerToDoList, j)
- set ListTime to (value(Sinistra(i, 2)) * 60) + value(Centro(i, 4, 5))
- if ListTime <= NowMinutes then
- deleteAt(gTimerToDoList, j)
- return 1
- end if
- end repeat
- return 0
- end
-
- on AskDeleteAllTimer
- DialogBoxSiNo("Would you delete the Timer list?", "DeleteAllTimer", "nothing")
- end
-
- on DeleteAllTimer
- global gTempTimerOnList, gTempTimerHourList, gTempTimerDayList, gMaxTimer, gNero
- updateStage()
- set stringa to " " & RETURN & " " & RETURN & " " & RETURN & " " & RETURN & " " & RETURN & " " & RETURN & " "
- put stringa into field "fHourList"
- put stringa into field "fDayList"
- set the foreColor of field "fOnOffTimer" to gNero
- set the foreColor of field "fHourList" to gNero
- repeat with i = 1 to gMaxTimer
- setAt(gTempTimerOnList, i, 1)
- setAt(gTempTimerHourList, i, " ")
- setAt(gTempTimerDayList, i, -1)
- end repeat
- end
-
- on ChkTimerBy mySprite, myRoll, myRadio
- global gTempTimerBy
- set myBtnUp to the name of member the member of sprite mySprite
- set myValue to value(the last char in myBtnUp)
- if myRadio = "TempTimerBy1" then
- set deltaSprite to 2
- else
- set deltaSprite to -2
- end if
- repeat while the stillDown
- if the rollOver = myRoll then
- set the member of sprite mySprite to BtnDw(myBtnUp)
- else
- set the member of sprite mySprite to myBtnUp
- end if
- updateStage()
- end repeat
- set the member of sprite mySprite to myBtnUp
- updateStage()
- if myValue = 1 then
- exit
- end if
- if the rollOver = myRoll then
- set gTempTimerBy to not gTempTimerBy
- put "0" into char length(myBtnUp) of myBtnUp
- set the member of sprite (mySprite + deltaSprite) to myBtnUp
- put "1" into char length(myBtnUp) of myBtnUp
- end if
- set the member of sprite mySprite to myBtnUp
- SetIngrigisceTimer()
- updateStage()
- end
-
- on SetIngrigisceTimer
- global gTempTimerAll, gTempTimerBy
- if not value(gTempTimerAll) then
- set myPoint to point(the left of sprite 17 + 1, the top of sprite 17 + 1)
- set the loc of sprite 100 to myPoint
- set the width of sprite 100 to 310
- else
- if gTempTimerBy = 0 then
- set theSprite to 17
- else
- set theSprite to 51
- end if
- set myPoint to point(the left of sprite theSprite + 1, the top of sprite theSprite + 1)
- set the loc of sprite 100 to myPoint
- set the width of sprite 100 to 155
- end if
- updateStage()
- end
-
- on MsgTimer
- global gStopTimerAll
- if gStopTimerAll then
- SpegniTimer()
- return " I turned off the Timer."
- else
- return EMPTY
- end if
- end
-
- on SpegniTimer
- global gTimerAll
- set gTimerAll to 0
- set the member of sprite 26 to member ("BtnUpTimer" & gTimerAll)
- updateStage()
- end
-